//
//  NSUserDefaults+Helpers.m
//
//
//  Created by Conner Wu.
//  Copyright (c) 2015年 Conner Wu. All rights reserved.
//

#import "NSUserDefaults+Helpers.h"

@implementation NSUserDefaults (Helpers)

+ (void)saveObject:(id)object forKey:(NSString *)key
{
    NSUserDefaults *defaults = [self standardUserDefaults];
    [defaults setObject:object forKey:key];
    [defaults synchronize];
}

+ (void)saveBool:(BOOL)bol forkey:(NSString *)key {
    [[NSUserDefaults standardUserDefaults] setBool:bol forKey:key];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

+ (void)deleteObjectForKey:(NSString *)key
{
    NSUserDefaults *defaults = [self standardUserDefaults];
    [defaults removeObjectForKey:key];
    [defaults synchronize];
}

+ (id)retrieveObjectForKey:(NSString *)key
{
    return [[self standardUserDefaults] objectForKey:key];
}

+ (void)removeAll {
    NSString *appDomainStr = [[NSBundle mainBundle] bundleIdentifier];
    [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomainStr];
}

@end
